﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Submarines
{
    public partial class Setup : UserControl
    {
        public bool _Done = false;
        Image _img;

        public Setup()
        {
            InitializeComponent();
        }

        void HSubmarine(int x, int y, int size)
        {
            Button Submarine = new Button();

            Submarine = new Button();
            Submarine.Location = new Point(x + 1, y);
            Submarine.Name = "H" + size.ToString();
            Submarine.Text = (5 - size).ToString();
            Submarine.ForeColor = Color.White;
            Submarine.Image = GetImage(true, size);
            Submarine.Font = new System.Drawing.Font("Showcard Gothic", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(177)));
            Submarine.TextAlign = ContentAlignment.MiddleLeft;
            Submarine.Tag = (5 - size).ToString();
            Submarine.Size = new Size(30 * size, 33);
            Submarine.MouseMove += new MouseEventHandler(Submarine_MouseMove);
            Controls.Add(Submarine);
        }

        private Image GetImage(bool horisntal, int lenght)
        {
            if (horisntal)
                switch (lenght)
                {
                    case 1:
                        _img = global::Submarines.Properties.Resources.Ship_H1;
                        break;
                    case 2:
                        _img = global::Submarines.Properties.Resources.Ship_H2;
                        break;
                    case 3:
                        _img = global::Submarines.Properties.Resources.Ship_H3;
                        break;
                    case 4:
                        _img = global::Submarines.Properties.Resources.Ship_H4;
                        break;

                    default:
                        _img = null;
                        break;
                }
            else
            {
                switch (lenght)
                {
                    case 1:
                        _img = global::Submarines.Properties.Resources.Ship_V1;
                        break;
                    case 2:
                        _img = global::Submarines.Properties.Resources.Ship_V2;
                        break;
                    case 3:
                        _img = global::Submarines.Properties.Resources.Ship_V3;
                        break;
                    case 4:
                        _img = global::Submarines.Properties.Resources.Ship_V4;
                        break;

                    default:
                        _img = null;
                        break;
                }

            }


            return _img;
        

        }

        void VSubmarine(int x, int y, int size)
        {
            Button Submarine = new Button();

            Submarine = new Button();
            Submarine.Location = new Point(x + 1, y);
            Submarine.Name = "V" + size.ToString();
            Submarine.ForeColor = Color.White;
            Submarine.Text = (5 - size).ToString();
            Submarine.Image = GetImage(false, size);
            Submarine.Font = new System.Drawing.Font("Showcard Gothic", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(177))); Submarine.TextAlign = ContentAlignment.TopCenter;
            Submarine.Tag = (5 - size).ToString();
            Submarine.Size = new Size(33, 30 * size);
            Submarine.MouseMove += new MouseEventHandler(Submarine_MouseMove);
            
            Controls.Add(Submarine);
        }

        void Submarine_MouseMove(object sender, MouseEventArgs e)
        {
            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
                DoDragDrop(sender, DragDropEffects.Link);
        }

        public void Setup_Load(object sender, EventArgs e)
        {
            HSubmarine(10, 10, 4);
            HSubmarine(10, 42, 3);
            HSubmarine(10, 74, 2);
            HSubmarine(10, 106, 1);

            VSubmarine(10, 140, 4);
            VSubmarine(40, 140, 3);
            VSubmarine(70, 140, 2);
            VSubmarine(100, 140, 1);
        }
    }
}
